const fs=require("fs");
const path=require("path");

function delDir(filePath){
    if(fs.existsSync(filePath)){
        var files=fs.readdirSync(filePath);
        for(var i=0;i<files.length;i++){
            var childPath=path.join(filePath,"/"+files[i]);
            var fileObj=fs.statSync(childPath);
            if(fileObj.isFile()){
                fs.unlinkSync(childPath);
            }else if(fileObj.isDirectory()){
                delDir(childPath);
            }
        }
        fs.rmdirSync(filePath);
    }else{
        console.log("文件路径不存在");
    }
}


var path=require("path");
var stdin=process.stdin;

console.log("请输入要创建的文件夹：\n");
stdin.on("data",function (chunk) {
  var file=chunk.toString("utf8");
  delDir(file);
})

